import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'

export default defineConfig(({command, mode}) => {
    const env = loadEnv(mode, process.cwd(), '')
    return {
        plugins: [vue()],
        // 路径别名
        resolve: {
            alias: {
                '@': path.resolve(__dirname, 'src')
            }
        },
        // css预处理器
        css: {
            preprocessorOptions: {
                scss: {
                    additionalData: '@import "@/assets/css/index.scss";',
                }
            },
        },
        server: {
            host: '0.0.0.0',
            port: 82,
            open: false,
            proxy: {
                [env.VITE_BASE_API]: {
                    target: "http://localhost:8888",
                    changeOrigin: true,
                    rewrite: (path) => path.replace(env.VITE_BASE_API, ''),
                }
            }
        },
    }
})
